package org.example3;

import java.util.ArrayList;
import java.util.List;

/**
 * -Xms300m -Xmx300m
 */
public class ErrorNotCatch {

  public static List<byte[]> list=new ArrayList<byte[]>();
    public static void main(String[] args) {
        System.out.println("Hello World!");
        byte[] bytes = new byte[1024 * 1024 * 5];
        list.add(bytes);
        list.add(bytes);


        System.out.println(  list.get(0) == list.get(1) );


        try {
            for (int i = 0; i < 10000; i++) {
                addToList();
            }
        } catch (Exception e) {
            System.out.println("Exception: ----------------"+list.size());
            e.printStackTrace();
        } catch (Throwable error) {
            System.out.println("Error: ----------------"+list.size());
            throw error;
//            error.printStackTrace();
        }
        System.out.println("Done.");
    }

    public static void addToList() {
        byte[] bytes = new byte[1024 * 1024];
        list.add(bytes);
    }
}
